<?php
if (!defined('ipos')) die("Please contact Y!m: ichphien_pro or Email: ichphien_pro@yahoo.com.");
if($levelTL != 3) {
	die("Bạn không đủ quyền để truy cập trang này!");
}
// add
if($mode == "add") {
	if($_POST['submit'])	{
		$p_title 		 = stripslashes(trim(urldecode($_POST['p_title'])));
		$p_contents		 = stripslashes(trim(urldecode($_POST['p_contents'])));
		$p_status 		 = stripslashes(trim(urldecode($_POST['p_status'])));
		if($p_title && $p_contents) {
			$db->dbinstall("pages","p_title,p_contents,p_status","'$p_title','$p_contents','$p_status'");
			header("Location: index.php?ipos=pages");
		}
	}
	include_once("./code/php/html_pages.php");
}
//edit
elseif($mode == "edit") {
	$pages			= $db->database("p_title,p_contents,p_status","pages","p_id = '$ipid'");
	$p_title 		= $pages[0][0];
	$p_contents 	= $pages[0][1];
	$p_status 		= $pages[0][2];
	if($_POST['submit'])	{
		$p_title 		 = stripslashes(trim(urldecode($_POST['p_title'])));
		$p_contents		 = stripslashes(trim(urldecode($_POST['p_contents'])));
		$p_status 		 = stripslashes(trim(urldecode($_POST['p_status'])));
		if($p_title && $p_contents) {
			$db->dbupdate("pages","p_title = '$p_title',
								p_contents = '$p_contents',
								p_status = '$p_status'","p_id = '$ipid'");
			header("Location: index.php?ipos=pages");
		}
	}
	include_once("./code/php/html_pages.php");
}
// delete
elseif($mode == "delete") {
	if($ipid) {
		$db->dbdelete("pages","p_id = '$ipid'");
		header("Location: index.php?ipos=pages");
	}
}

// list
else {
	include_once("./code/php/html_pages_list.php");
}
?>